// AUSlotsTesterDoc.h : interface of the CAUSlotsTesterDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_AUSLOTSTESTERDOC_H__9E0AE286_0484_4608_B57C_3FBF1D8A05AF__INCLUDED_)
#define AFX_AUSLOTSTESTERDOC_H__9E0AE286_0484_4608_B57C_3FBF1D8A05AF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "BonusGameArray.h"
#include "IconArray.h"
#include "PayoutTypeArray.h"
#include "GameModeArray.h"
#include "SpinTester.h"
#include "SQLServerSession.h"

#include "DocumentHomeWebPage.h"
#include "DocumentStatisticalAnalysisWebPage.h"
#include "DocumentPayoutHistoryWebPage.h"
#include "DocumentPayoutGraphWebPage.h"
#include "DocumentPayoutGraphBitmapFile.h"
#include "DocumentReportWebPage.h"
#include "DocumentGameModeWebPage.h"

class CAUSlotsTesterDoc : public CDocument
{
protected: // create from serialization only
	CAUSlotsTesterDoc();
	DECLARE_DYNCREATE(CAUSlotsTesterDoc)

public:
	virtual void OnIdle();

	bool OpenDataSource( LPCTSTR szSQLServer, bool bUseIntegratedSecurity, LPCTSTR szUser, LPCTSTR szPassword, LPCTSTR szDatabase );

	bool SetSlotServer( LPCTSTR szServer, UINT nPort, int nSlotGutID );
	
	LPCTSTR GetSlotServerName() const;
	UINT GetSlotServerPort() const;
	int GetSlotGutID() const;

	enum SPIN_STATE
	{
		ssStopped,
		ssSpinning,
		ssStopping
	};

	SPIN_STATE GetSpinState() const;

	const CSpinTestResults& GetResults() const;

	void Spin( bool bSpin );
	bool IsSpinning() const;

	void SetAutoSave( bool bAutoSave );
	bool IsAutoSaveOn() const;

	LPCTSTR GetHomeURL() const;
	LPCTSTR GetStatisticalAnalysisURL() const;
	LPCTSTR GetPayoutHistoryURL() const;
	LPCTSTR GetPayoutGraphURL() const;
	LPCTSTR GetPayoutGraphImageURL() const;
	LPCTSTR GetFullReportURL() const;
	LPCTSTR GetGameModeURL( int nGameMode ) const;

	typedef CArray< double, double& > CPayoutHistoryArray;

	const CPayoutHistoryArray& GetPayoutHistoryArray() const;

	int GetPaidLinesPerBatch() const;
	int GetLinesPerSpin() const;
	int GetBetPerLine() const;

	LPCTSTR GetGameModeName( int nGameMode ) const;
	LPCTSTR GetIconName( int nIcon ) const;
	LPCTSTR GetBonusGameTypeName( int nBonusGameType ) const;
	LPCTSTR GetPayoutTypeName( int nPayoutType ) const;

	const CGameModeArray& GetGameModeArray() const;

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAUSlotsTesterDoc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CAUSlotsTesterDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CAUSlotsTesterDoc)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

private:
	void LoadBonusGameTypes();
	void LoadIconNames();
	void LoadPayoutTypes();
	void LoadGameModes();

	void SetWebPageDirty();

	void OnSpinResultsReady( const CSpinTestResults* pSpinResults );
	void OnSpinResultsFailed();

private:
	CString m_strSlotMachineName;
	CString m_strSQLServer;
	bool m_bUseIntegratedSecurity;
	CString m_strDatabase;
	CString m_strSlotServer;
	UINT m_nSlotPort;
	int m_nSlotGutID;
	bool m_bSpinning;
	int m_nSpinsPerBatch;
	int m_nLinesPerSpin;
	int m_nBetPerLine;
	bool m_bAutoSave;

	CBonusGameArray m_aBonusGames;
	CIconArray m_aIcons;
	CPayoutTypeArray m_aPayoutTypes;
	CGameModeArray m_aGameModes;

	CSQLServerSession m_Session;
	CSpinTester m_SpinTester;
	CSpinTestResults m_Results;
	CPayoutHistoryArray m_aPayoutHistory;

	CDocumentHomeWebPage m_wpHome;
	CDocumentStatisticalAnalysisWebPage m_wpStatisticalAnalysis;
	CDocumentPayoutHistoryWebPage m_wpPayoutHistory;
	CDocumentPayoutGraphWebPage m_wpPayoutGraph;
	CDocumentPayoutGraphBitmapFile m_bfPayoutGraphImage;
	CDocumentReportWebPage m_wpFullReport;
	CArray< CDocumentGameModeWebPage*, CDocumentGameModeWebPage* > m_awpGameModes;
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_AUSLOTSTESTERDOC_H__9E0AE286_0484_4608_B57C_3FBF1D8A05AF__INCLUDED_)
